<?xml version='1.0' encoding="utf-8" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version='1.0'
		             xmlns:date="http://exslt.org/dates-and-times">

<xsl:import href="ctl-cpp-common.xsl"/>
<xsl:output method="text" indent="yes" encoding="utf-8"/>

<xsl:variable name="CLASSNAME">
	<xsl:call-template name="settings"><xsl:with-param name="varname" select="'class-name'"/></xsl:call-template>
</xsl:variable>
<xsl:variable name="BASECLASS">
	<xsl:call-template name="settings"><xsl:with-param name="varname" select="'base-class'"/></xsl:call-template>
</xsl:variable>
<xsl:variable name="OID">
	<xsl:call-template name="settings"><xsl:with-param name="varname" select="'ID'"/></xsl:call-template>
</xsl:variable>
<xsl:variable name="TESTMODE">
	<xsl:call-template name="settings"><xsl:with-param name="varname" select="'testmode'"/></xsl:call-template>
</xsl:variable>
<xsl:variable name="ARGPREFIX">
	<xsl:call-template name="settings"><xsl:with-param name="varname" select="'arg-prefix'"/></xsl:call-template>
</xsl:variable>

<!-- Генерирование заголовочного файла -->
<xsl:template match="/">
// --------------------------------------------------------------------------
/*
 DO NOT EDIT THIS FILE. IT IS AUTOGENERATED FILE.
 ALL YOUR CHANGES WILL BE LOST.
 
 НЕ РЕДАКТИРУЙТЕ ЭТОТ ФАЙЛ. ЭТОТ ФАЙЛ СОЗДАН АВТОМАТИЧЕСКИ.
 ВСЕ ВАШИ ИЗМЕНЕНИЯ БУДУТ ПОТЕРЯНЫ.
*/ 
// --------------------------------------------------------------------------
// generate timestamp: <xsl:value-of select="date:date()"/>
// -----------------------------------------------------------------------------
#ifndef <xsl:value-of select="$CLASSNAME"/>_SK_H_
#define <xsl:value-of select="$CLASSNAME"/>_SK_H_
// -----------------------------------------------------------------------------
#include &lt;memory&gt;
#include &lt;string&gt;
#include &lt;unordered_map&gt;
#include &lt;sstream&gt;
<xsl:if test="normalize-space($BASECLASS)!=''">#include <xsl:call-template name="preinclude"/><xsl:value-of select="normalize-space($BASECLASS)"/>.h<xsl:call-template name="postinclude"/></xsl:if>
<xsl:if test="normalize-space($BASECLASS)=''">#include <xsl:call-template name="preinclude"/>UniSetObject.h<xsl:call-template name="postinclude"/></xsl:if>
#include <xsl:call-template name="preinclude"/>UniXML.h<xsl:call-template name="postinclude"/>
#include <xsl:call-template name="preinclude"/>Trigger.h<xsl:call-template name="postinclude"/>
#include <xsl:call-template name="preinclude"/>DebugStream.h<xsl:call-template name="postinclude"/>
#include <xsl:call-template name="preinclude"/>LogServer.h<xsl:call-template name="postinclude"/>
#include <xsl:call-template name="preinclude"/>LogAgregator.h<xsl:call-template name="postinclude"/>
#include <xsl:call-template name="preinclude"/>VMonitor.h<xsl:call-template name="postinclude"/>
// -----------------------------------------------------------------------------
class <xsl:value-of select="$CLASSNAME"/>_SK:
<xsl:choose>
	<xsl:when test="normalize-space($BASECLASS)='UniSetObject'">	public uniset::UniSetObject</xsl:when>
	<xsl:when test="normalize-space($BASECLASS)='UniSetManager'">	public uniset::UniSetManager</xsl:when>
	<xsl:when test="normalize-space($BASECLASS)!=''">	public <xsl:value-of select="normalize-space($BASECLASS)"/></xsl:when>
	<xsl:when test="normalize-space($BASECLASS)=''">	public uniset::UniSetObject</xsl:when>
</xsl:choose>
{
	public:
		<xsl:if test="not(normalize-space($OID))=''">
				<xsl:value-of select="$CLASSNAME"/>_SK( uniset::ObjectId id = uniset::uniset_conf()->getObjectID("<xsl:value-of select="$OID"/>"), xmlNode* node=uniset::uniset_conf()->getNode("<xsl:value-of select="normalize-space($CNAME)"/>"), const std::string&amp; argprefix="<xsl:value-of select="normalize-space($ARGPREFIX)"/>", xmlNode* globalConfNode=nullptr );
		</xsl:if>
		<xsl:if test="normalize-space($OID)=''">
				<xsl:value-of select="$CLASSNAME"/>_SK( uniset::ObjectId id, xmlNode* node=uniset::uniset_conf()->getNode("<xsl:value-of select="normalize-space($CNAME)"/>"), const std::string&amp; argprefix="<xsl:value-of select="normalize-space($ARGPREFIX)"/>", xmlNode* globalConfNode=nullptr );
		</xsl:if>
		<xsl:value-of select="$CLASSNAME"/>_SK();
		virtual ~<xsl:value-of select="$CLASSNAME"/>_SK();

		<xsl:call-template name="COMMON-HEAD-PUBLIC"/>

		// Используемые идентификаторы
		<xsl:for-each select="//smap/item">
		const uniset::ObjectId <xsl:value-of select="@name"/>; 		/*!&lt; <xsl:value-of select="@comment"/> */
		const uniset::ObjectId node_<xsl:value-of select="@name"/>;
		<xsl:if test="normalize-space(@vartype)='io'">#error (uniset-codegen): vartype='io' NO LONGER SUPPORTED! (ignore variable: '<xsl:value-of select="@name"/>')
		</xsl:if>
		</xsl:for-each>

		// Используемые идентификаторы сообщений
		<xsl:for-each select="//msgmap/item">
		const uniset::ObjectId <xsl:value-of select="@name"/>; 	/*!&lt; <xsl:value-of select="@comment"/> */
		const uniset::ObjectId node_<xsl:value-of select="@name"/>;
		bool m_<xsl:value-of select="@name"/>; 							/*!&lt; текущее состояние /> */
		</xsl:for-each>

		// Текущее значение
		<xsl:for-each select="//smap/item">
		<xsl:if test="normalize-space(@vartype)='in'">const long&amp; </xsl:if>
		<xsl:if test="normalize-space(@vartype)!='in'">long </xsl:if>
		<xsl:call-template name="setprefix"/><xsl:value-of select="@name"/>;
		</xsl:for-each>

		// --- public variables ---
		<xsl:text>
		</xsl:text>
		<xsl:for-each select="//variables/item">
        <xsl:if test="normalize-space(@public)!=''">
    		<xsl:if test="normalize-space(@type)!=''"><xsl:if test="normalize-space(@const)!=''">const </xsl:if></xsl:if>
		<xsl:if test="normalize-space(@type)='int'">int <xsl:value-of select="@name"/>; /*!&lt; <xsl:value-of select="@comment"/> */
		</xsl:if>
		<xsl:if test="normalize-space(@type)='long'">long <xsl:value-of select="@name"/>; /*!&lt; <xsl:value-of select="@comment"/> */
		</xsl:if>
		<xsl:if test="normalize-space(@type)='float'">float <xsl:value-of select="@name"/>; /*!&lt; <xsl:value-of select="@comment"/> */
		</xsl:if>
		<xsl:if test="normalize-space(@type)='double'">double <xsl:value-of select="@name"/>; /*!&lt; <xsl:value-of select="@comment"/> */
		</xsl:if>
		<xsl:if test="normalize-space(@type)='bool'">bool <xsl:value-of select="@name"/>; /*!&lt; <xsl:value-of select="@comment"/> */
		</xsl:if>
		<xsl:if test="normalize-space(@type)='str'">std::string <xsl:value-of select="@name"/>; /*!&lt; <xsl:value-of select="@comment"/> */
		</xsl:if>
		<xsl:if test="normalize-space(@type)='sensor'">uniset::ObjectId <xsl:value-of select="@name"/>; /*!&lt; <xsl:value-of select="@comment"/> */
		</xsl:if>
		<xsl:if test="normalize-space(@type)='object'">uniset::ObjectId <xsl:value-of select="@name"/>; /*!&lt; <xsl:value-of select="@comment"/> */
		</xsl:if>
		</xsl:if>
		</xsl:for-each>
		// --- end of public variables ---

	protected:
		// --- protected variables ---
		<xsl:text>
		</xsl:text>
		<xsl:for-each select="//variables/item">
        <xsl:if test="normalize-space(@private)=''">
		<xsl:if test="normalize-space(@public)=''">
		<xsl:if test="normalize-space(@type)!=''"><xsl:if test="normalize-space(@const)!=''">const </xsl:if></xsl:if>
		<xsl:if test="normalize-space(@type)='int'">int <xsl:value-of select="@name"/>; /*!&lt; <xsl:value-of select="@comment"/> */
		</xsl:if>
		<xsl:if test="normalize-space(@type)='long'">long <xsl:value-of select="@name"/>; /*!&lt; <xsl:value-of select="@comment"/> */
		</xsl:if>
		<xsl:if test="normalize-space(@type)='float'">float <xsl:value-of select="@name"/>; /*!&lt; <xsl:value-of select="@comment"/> */
		</xsl:if>
		<xsl:if test="normalize-space(@type)='double'">double <xsl:value-of select="@name"/>; /*!&lt; <xsl:value-of select="@comment"/> */
		</xsl:if>
		<xsl:if test="normalize-space(@type)='bool'">bool <xsl:value-of select="@name"/>; /*!&lt; <xsl:value-of select="@comment"/> */
		</xsl:if>
		<xsl:if test="normalize-space(@type)='str'">std::string <xsl:value-of select="@name"/>; /*!&lt; <xsl:value-of select="@comment"/> */
		</xsl:if>
		<xsl:if test="normalize-space(@type)='sensor'">uniset::ObjectId <xsl:value-of select="@name"/>; /*!&lt; <xsl:value-of select="@comment"/> */
		</xsl:if>
		<xsl:if test="normalize-space(@type)='object'">uniset::ObjectId <xsl:value-of select="@name"/>; /*!&lt; <xsl:value-of select="@comment"/> */
		</xsl:if>
		</xsl:if>
		</xsl:if>
		</xsl:for-each>
		// ---- end of protected variables ----

		<xsl:call-template name="COMMON-HEAD-PROTECTED"/>

	private:
		<xsl:text>
		</xsl:text>// --- private variables ---
		<xsl:for-each select="//variables/item">
        <xsl:if test="normalize-space(@private)!=''">
		<xsl:if test="normalize-space(@const)!=''">const </xsl:if>
		<xsl:if test="normalize-space(@type)='int'">int <xsl:value-of select="@name"/>; /*!&lt; <xsl:value-of select="@comment"/> */
		</xsl:if>
		<xsl:if test="normalize-space(@type)='long'">long <xsl:value-of select="@name"/>; /*!&lt; <xsl:value-of select="@comment"/> */
		</xsl:if>
		<xsl:if test="normalize-space(@type)='float'">float <xsl:value-of select="@name"/>; /*!&lt; <xsl:value-of select="@comment"/> */
		</xsl:if>
		<xsl:if test="normalize-space(@type)='double'">double <xsl:value-of select="@name"/>; /*!&lt; <xsl:value-of select="@comment"/> */
		</xsl:if>
		<xsl:if test="normalize-space(@type)='bool'">bool <xsl:value-of select="@name"/>; /*!&lt; <xsl:value-of select="@comment"/> */
		</xsl:if>
		<xsl:if test="normalize-space(@type)='str'">std::string <xsl:value-of select="@name"/>; /*!&lt; <xsl:value-of select="@comment"/> */
		</xsl:if>
		<xsl:if test="normalize-space(@type)='sensor'">uniset::ObjectId <xsl:value-of select="@name"/>; /*!&lt; <xsl:value-of select="@comment"/> */
		</xsl:if>
		</xsl:if>
		</xsl:for-each>// --- end of private variables ---

		// предыдущее значение (для работы UpdateValue())
		<xsl:for-each select="//smap/item">long prev_<xsl:call-template name="setprefix"/><xsl:value-of select="@name"/>;
		</xsl:for-each>
		
		// Текущее значение (rw-переменные)
		<xsl:for-each select="//smap/item"><xsl:if test="normalize-space(@vartype)='in'">long priv_<xsl:call-template name="setprefix"/><xsl:value-of select="@name"/>;
		</xsl:if>
		</xsl:for-each>

		// Используемые идентификаторы сообщений
		<xsl:for-each select="//msgmap/item">bool prev_m_<xsl:value-of select="@name"/>; /*!&lt; предыдущее состояние /> */
		</xsl:for-each>

		<xsl:call-template name="COMMON-HEAD-PRIVATE"/>

		bool end_private; // вспомогательное поле (для внутреннего использования при генерировании кода)
};

// -----------------------------------------------------------------------------
#endif // <xsl:value-of select="$CLASSNAME"/>_SK_H_
</xsl:template>
</xsl:stylesheet>
